<?php

class Category_model extends Model
{
	// Protected or private properties
	protected $_table;
	
	// Constructor
	public function __construct()
	{
		parent::Model();

		// Load needed models, libraries, helpers and language files
		//$this->load->module_model('blog', 'category_model', 'category');
		
		$this->_table = $this->config->item('database_tables');
	}

	// Public methods
	public function get_the_last_sticky_post($lang_id=2)
	{
		$this->db->select_max('news.id','ID');
		$this->db->from($this->_table['news'] . ' news');
		$this->db->where('news.status', '1');
		$this->db->where('news.lang_id',$lang_id);
		$this->db->where('news.type','n');	
		$this->db->where('news.sticky','1');	
			
		$query = $this->db->get();
			
		if ($query->num_rows() > 0)
		{
			$last_id = $query->result_array();
		}
		
		$result = $this->get_post_by_id($last_id[0]['ID']);
		return $result;
	}
	public function get_category($id)
	{
		$this->db->select('s_category.*');
		$this->db->from($this->_table['s_category'] . ' s_category');
		$this->db->where('s_category.status', 1);
		$this->db->where('s_category.id', $id);
		$this->db->limit(1);
		
		$query = $this->db->get();
			
		if ($query->num_rows() > 0)
		{
			$result = $query->result_array();
			return $result[0];
		}
		return null;
	}
}

/* End of file blog_model.php */
/* Location: ./application/modules/blog/models/blog_model.php */